pip install Flask

Create a folder name SimpleRESTService, 

Create a python Filename: app.py

Code:
from flask import Flask, jsonify, request
app = Flask(__name__)

# Sample data
data = [
    {'id': 1, 'name': 'Item 1'},
    {'id': 2, 'name': 'Item 2'},
]

# Endpoint to get all items
@app.route('/items', methods=['GET'])
def get_items():
    return jsonify({'items': data})

# Endpoint to get a specific item by ID
@app.route('/items/<int:item_id>', methods=['GET'])
def get_item(item_id):
    item = next((item for item in data if item['id'] == item_id), None)
    if item:
        return jsonify({'item': item})
    else:
        return jsonify({'message': 'Item not found'}), 404






# Endpoint to add a new item
@app.route('/items', methods=['POST'])
def add_item():
    new_item = {'id': len(data) + 1, 'name': request.json['name']}
    data.append(new_item)
    return jsonify({'message': 'Item added successfully', 'item': new_item}), 201

# Run the application
if __name__ == '__main__':
    app.run(debug=True)


Run the app.py from cmd

python app.py

Open Postman
# Endpoint to get all items
Send a GET Request:
URL: http://127.0.0.1:5000/items

# Endpoint to add a new item
Send a POST Request:
URL: http://127.0.0.1:5000/items
Body: Set the body to raw JSON and include:
{"name":"item3"}


# Endpoint to get a specific item by ID
Send a GET Request:
URL: http://127.0.0.1:5000/items/1

Throws Error when not item not found from Sample Data. Example 
URL: http://127.0.0.1:5000/items/100
